/**
 * 
 */
package soa.security.mgr.service;

import java.util.List;
import java.util.Map;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import soa.security.domain.Department;
import soa.security.domain.Group;
import soa.security.domain.Organization;
import soa.security.domain.Person;
import soa.security.domain.Position;
import soa.security.exception.OrganizationException;
import soa.security.mgr.service.base.BaseMgrService;
import soa.security.ws.base.ModelAdapter;

/**
 * @author CreGu
 *
 */
public interface PersonMgrService extends BaseMgrService, ModelAdapter<Person> {

	void addPerson(String organizationId, Person person)
			throws OrganizationException;
	
	void addPersonRe(String organizationId, Person person, Department dep)
			throws OrganizationException;

	void updatePerson(String organizationId, Person person)
			throws OrganizationException;

	List<Person> allPersons(String organizationId) throws OrganizationException;
	
	Page<Person> allPersons(String organizationId,
			Map<String, Object> parameters, boolean subTree, PageRequest request)
			throws OrganizationException;

	List<Person> allPersons(String organizationId,
			Map<String, Object> parameters, boolean subTree)
			throws OrganizationException;

	List<Person> allPersonsOnlyInOrganization(String organizationId);

	List<Person> allPersons(List<Person> all, List<Person> allPersons);
	
	Page<Person> allPersons(List<Person> all, List<Person> deptPersons, PageRequest request);

	List<Person> getPerson(String organizationId, String personId)
			throws OrganizationException;

	Person findByDn(String dn) throws OrganizationException;

	boolean deleteByDn(String dn) throws OrganizationException;

	List<Person> filterPersons(List<Person> all, List<Person> filters,
			String organizationId);

	Person findByUid(String uid, String organizationId);

	List<Group> findGroups(String organizationId, String dn);

	List<Position> findPositions(String organizationId, String dn);

	void addPerson4Mgr(String organizationId, Person model,
			String departmentDns, String positionDns, String groupDns)
			throws OrganizationException;

	void updatePerson4Mgr(String organizationId, Person model,
			String departmentDns, String positionDns, String groupDns)
			throws OrganizationException;

	void remove(String organizationId, String dn);

	Organization belongs(Person person);
	
	public List<Person> findByOrgAndName(String organizationId, String cname);
}
